﻿using System;
using System.Web;

namespace Nydus.WebForms.FrontendModel
{
    public abstract class BasePresenterFactory : IPresenterFactory
    {
        public abstract object GetPresenter(HttpContextBase httpContextBase, BasePage page);

        protected static Type GetPresenterType(BasePage page)
        {
            Type presenterType = null;
            System.Attribute[] attrs = System.Attribute.GetCustomAttributes(page.GetType());
            foreach (System.Attribute attr in attrs)
            {
                if (attr is PresenterTypeAttribute)
                {
                    PresenterTypeAttribute a = (PresenterTypeAttribute)attr;
                    presenterType = a.PresenterType;
                }
            }
            return presenterType;
        }
    }
}
